// pages/home/home.js
var util = require('../../utils/util.js');
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
      userInfo:'',
      grids: [0, 1, 2, 3, 4, 5, 6, 7, 8],
      btnName: [{ id: 1, btnName: '预约', url: '/pages/aduting/resversion/resersion_list', img:'/images/yuyue.png'},
        { id: 2, btnName: '租约', url: '/pages/select/renterUser/user_select', img:'/images/order.png'},
        { id: 8, btnName: '开锁', url: '/pages/home/onpenLock/openLock_list', img: '/images/kaisuo.png' },
        { id: 9, btnName: '水电煤', url: '/pages/home/sd/sd_list', img: '/images/chaobiao.png' },
        { id: 10, btnName: '入住登记', url: '/pages/select/userinfo/userinfo', img: '/images/ruzhudengji.png' },
        { id: 11, btnName: '租客登记', url: '/pages/select/renterinfo/renterinfo', img: '/images/zukedengji.png' }
       

      ],
      dataMap: { fastExpiryLease: '', fastExpiryLeaseNum: '', newOrderNum: '', newReserve: '' 
        , newReserveNum: '', oweRent: '', oweRentNum: '', oweWater: '', oweWaterNum: '', retreatRoom: ''
        , retreatRoomNum:''
          
      },
     
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onShow:function(){
    var that = this;
    wx.getStorage({
      key: 'userInfo',
      success: function (res) {
        that.setData({
          userInfo: res.data
        })
        if (res.data.user_type_id == 10006) {
          app.editTabBar2();
        } else {
          app.editTabBar();
        }
        util.getReq("/app/home/homeDataInterface", { source: res.data.source, uid: res.data.user_id }, function (data) {

          if (data.code == 0) {

            that.getDataTypes(data.params);

          } else {
            wx.showModal({
              title: '错误',
              content: data.desc,
              mode: true,
              showCancel: false,
              confirmColor: '#007aff',
            })
          }
        });
      }, fail: function () {
        wx.redirectTo({
          url: '/pages/index/index',
        })
      }
    });

  },
  onLoad: function (options) {
    app.editTabBar();
  },
  //数据显示
  getDataTypes:function(data) {
    var that=this;
    that.setData({
      dataMap: {
        fastExpiryLease: data.fastExpiryLease, 
        fastExpiryLeaseNum: data.fastExpiryLeaseNum, 
        newOrderNum: data.newOrderNum,
         newReserve: data.newReserve,
         newReserveNum: data.newReserveNum,
         oweRent: data.oweRent, 
         oweRentNum: data.oweRentNum,
          oweWater: data.oweWater, 
          oweWaterNum:data.oweWaterNum, 
          retreatRoom: data.retreatRoom,
          retreatRoomNum: data.retreatRoomNum
      },
    })

  },


 
})